package com.vang

/*
Customer Domain Requirements
A Customer represents an account required to list or bid at AuctionHaus. Customers have the following requirements:
Done C-1: Customers have email address, password and created date fields (unit test)
Done C-2: Email address must be a unique field (integration test)
Done C-3: Email address must be of a valid form (*@*.*) (integration test)
Done C-4: Password must be between 6-8 characters (integration test)
*/
class Customer {

	String emailAddress;
	String password; // must be 6-8 characters
	Date createdDate;

	// customer can have many bids
    static mappedBy = [listings:'seller', winnings:'winner'];
	static hasMany = [listings:Listing, winnings:Listing, bids:Bid];

	static constraints = {
		// must be unique, must be the form *@*.*
		emailAddress(email:true, blank:false, nullable:false, unique:true);
		// 6 to eight character constant is stupid!!!! stupid!!! I would never do this
		// it is insecure and god just really stupid in all sense of stupidity, but I will
		// put it here because it's in the assignment.
		password(password: true, size:6..8, blank: false, nullable:false);

		createdDate(nullable: false);

		listings(nullable: true);
        winnings(nullable: true);
	}
}
